package cn.stylefeng.qz.core.util;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Maps;

import java.util.Map;

/**
 * 用来简化统计数据的执行
 * 在MyPaginationInterceptor对sql语句做count时，根据statCols插入的
 * 扩展参数，同时进行sum等聚合函数处理，结果放入statVals中
 *
 * @param <T>
 */
public class PageForStat<T>  extends Page<T> {
    protected Map<String, String> statCols;
    protected Map<String, Object> statVals;

    public PageForStat(long current, long size) {
        super(current, size);
    }

    public void addStatCol(String colAlias, String col){
        if (statCols == null){
            statCols = Maps.newLinkedHashMap();
        }
        statCols.put(colAlias, col);
    }

    @JsonIgnore
    public Map<String, String> getStatCols() {
        return statCols;
    }

    public Map<String, Object> getStatVals() {
        return statVals;
    }

    public void setStatVals(Map<String, Object> statVals) {
        this.statVals = statVals;
    }
}
